<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>

    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }

      .two {
        width: 400px;
        height: 1000px;
        margin: 0 auto;
        background-color: lightblue;
      }

      .one {
        width: 400px;
        height: 150px;
        margin: 0 auto;
        background-color: lightblue;
      }

      .btn {
        height: 30px;
        line-height: 30px;
        border: 1px lightseagreen solid;
        border-radius: 2px;
        display: inline-block;
        text-align: center;
        padding: 0px 10px;
        background-color: lightseagreen;
        color: white;
      }
    </style>
  </head>
  <body>
    <div class="two"></div>
    <div class="one"><div class="btn">确认</div></div>

    <script>
      $(document).ready(function() {
        $(".one").click(function(e) {
          console.log($(".one"));
          console.log($(".one").offset().top, "offset.top");
          console.log($(".one").offset().left, "offset.left");
          console.log($(window).scrollTop(), "$(window).scrollTop()");

          console.log(
            document.documentElement.scrollTop,
            "document.documentElement.scrollTop"
          );
          console.log(window.pageYOffset, "window.pageYOffset");
          console.log(document.body.scrollTop, "document.body.scrollTop");

          console.log(
            $(".one").offset().top - $(window).scrollTop(),
            "距上面高度"
          );

          console.log($("body").offset().top, "offset.top");
          console.log($("body").offset().left, "offset.left");

        var screenLeft=window.screenLeft;
        var screenTop=window.screenTop;


        });
      });
    </script>
  </body>
</html>
